%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% Welcome to writeLaTeX --- just edit your LaTeX on the left,
% and we'll compile it for you on the right. If you give
% someone the link to this page, they can edit at the same
% time. See the help menu above for more info. Enjoy!
%
% Note: you can export the pdf to see the result at full
% resolution.
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

% Line plot example using external data fiels.
%
% Author: Shino


\documentclass[letterpaper,12pt,titlepage]{article}
\usepackage{array}
\usepackage{graphicx}
\usepackage{float}
\usepackage{courier}
\usepackage{ulem}
\usepackage{pgfplots}
\usepackage{tikz}
\usetikzlibrary{plotmarks}

%%%<
\usepackage{verbatim}
%\usepackage[active,tightpage]{preview}
%\PreviewEnvironment{tikzpicture}
%\setlength\PreviewBorder{5pt}%
%%%>

\begin{comment}
:Title:  Line Plot Example
:Tags: Plotting; Plots
:Author: Claudio Favi
\end{comment}

% The data files, written on the first run.
\begin{filecontents}{ws1.data}
#droprate 	ratio
5	0.87
10	0.82
15	0.74
20	0.63
25	0.54
30	0.51
35	0.43
40	0.37
45	0.28
50	0.26
\end{filecontents}

\begin{filecontents}{ws3.data}
#droprate 	ratio
5	 0.87
10	0.77
15	0.64
20	0.57
25	0.52
30	0.43
35	 0.35
40	 0.30
45	0.27
50	0.23 
\end{filecontents}

\begin{filecontents}{ws5.data}
#droprate 	ratio
5	 0.78
10	0.72
15	0.55
20	0.43
25	0.36
30	0.34
35	 0.27
40	 0.24
45	0.21
50	0.18
\end{filecontents}

\begin{filecontents}{ws11.data}
#droprate 	ratio
5	 0.63
10	0.41
15	0.30
20	0.23
25	0.18
30	0.16
35	 0.12
40	 0.11
45	0.08
50	0.08
\end{filecontents}

\begin{filecontents}{ws19.data}
#droprate 	ratio
5	 0.64
10	0.43
15	0.27
20	0.18
25	0.13
30	0.12
35	 0.10
40	 0.07
45	0.06
50	0.05
\end{filecontents}

\begin{filecontents}{delay1.data}
#droprate 	ratio
5	 0.91
10	0.84
15	0.80
20	0.74
25	0.73
30	0.68
35	 0.62
40	 0.63
45	0.71
50	0.60
\end{filecontents}

\begin{filecontents}{delay5.data}
#droprate 	ratio
5	 0.84
10	0.77
15	0.68
20	0.63
25	0.48
30	0.45
35	 0.44
40	 0.48
45	0.39
50	0.45
\end{filecontents}


\begin{filecontents}{delay11.data}
#delayrate 	ratio
5	 0.79
10	0.44
15	0.45
20	0.39
25	0.35
30	0.33
35	 0.34
40	 0.28
45	0.23
50	0.18
\end{filecontents}


\begin{filecontents}{delay19.data}
#droprate 	ratio
5	 0.77
10	0.38
15	0.38
20	0.26
25	0.17
30	0.20
35	 0.17
40	 0.19
45	0.15
50	0.14
\end{filecontents}

\begin{document}

\title{COMP6461}
\setcounter{tocdepth}{2}
\newpage
\begin{center}
{\bf\ COMP6461:Communication Network \& Protocols}

$\mathcal{L}$ab $\mathcal{A}$ssignment 3

$\mathcal{P}$erformance $\mathcal{E}$valuation

\vspace{1cm}
\hspace{1cm} Student:Xiaodong Li \hspace{5cm} Student ID:7136609 \hspace{1cm}
\vspace{0.1cm}
\uuline{
\hspace{1cm} Student:Xuefei Shi \hspace{5.15cm} Student ID:6832407 \hspace{1cm}
}
\vspace{0.1cm}
\end{center}
\begin{enumerate}
\item File Transfer Data Collected
\begin{itemize}
\item
The following tables contains the neccesary data we need to compute the ratio of minimum required packet number and actual number of packets sent when the window size and the drop rate of packets changes, keeping the delay rates to 0.

As the results vary, for each window size and drop rate, we did three times of get function and used the average result for further computation.

In all the testing work, we used an binary file size of 41,404 bytes, which could be divided into 163 packets.
\begin{table}[H]
\begin{tabular}{l|llllll}
drop rate & required & actual 1 & actual 2 & actual 3 & avg actual & ratio \\ \hline
5\%       & 163       & 190       & 185       & 187       & 187.33      & 0.87  \\
10\%      & 163       & 195       & 200       & 203       & 199.33      & 0.82  \\
15\%      & 163      & 226       & 213       & 203       & 219.33     & 0.74  \\
20\%      & 163       & 260       & 262       & 257       & 259.67      & 0.63  \\
25\%      & 163       & 290       & 284       & 325       & 299.67      & 0.54  \\
30\%      & 163       & 316       & 333       & 313       & 320.67      & 0.51  \\
35\%      & 163       & 400       & 350       & 394       & 381.33     & 0.43  \\
40\%      & 163       & 466       & 424       & 427       & 439 .00     & 0.37  \\
45\%      & 163       & 585       & 598       & 533       & 572.00      & 0.28  \\
50\%      & 163       & 630       & 615       & 664       & 636.33      & 0.26 
\end{tabular}
\caption{Window Size=1}
\label{my-label}
\end{table}

\begin{table}[H]
\begin{tabular}{l|llllll}
drop rate & required & actual 1 & actual 2 & actual 3 & avg actual & ratio \\ \hline
5\%       & 163       & 193       & 193       & 178       & 188.00      & 0.87  \\
10\%      & 163       & 220       & 211       & 202       & 211.00      & 0.77  \\
15\%      & 163       & 257       & 259       & 244       & 253.33      & 0.64  \\
20\%      & 163       & 308       & 263       & 280       & 283.67      & 0.57  \\
25\%      & 163       & 343       & 292       & 301       & 312.00      & 0.52  \\
30\%      & 163       & 345       & 358       & 415       & 372.67      & 0.44  \\
35\%      & 163       & 512       & 403       & 484       & 466.33      & 0.35  \\
40\%      & 163       & 596       & 514       & 504       & 538.00      & 0.30  \\
45\%      & 163       & 674       & 618       & 535       & 609.00      & 0.27  \\
50\%      & 163       & 724       & 740       & 678       & 714.00      & 0.23 
\end{tabular}
\caption{Window Size=3}
\label{my-label}
\end{table}

\begin{table}[H]
\begin{tabular}{l|llllll}
drop rate & required & actual 1 & actual 2 & actual 3 & avg actual & ratio \\ \hline
5\%       & 163       & 223       & 193       & 208       & 208.00      & 0.78  \\
10\%      & 163       & 243       & 233       & 199       & 225.00      & 0.72  \\
15\%      & 163       & 283       & 291       & 306       & 293.33      & 0.55  \\
20\%      & 163       & 408       & 313       & 423       & 381.33      & 0.43  \\
25\%      & 163       & 456       & 493       & 410       & 453.00      & 0.36  \\
30\%      & 163       & 493       & 442       & 486       & 473.67      & 0.34  \\
35\%      & 163       & 588       & 580       & 668       & 612.00      & 0.27  \\
40\%      & 163       & 648       & 709       & 653       & 670.00      & 0.24  \\
45\%      & 163       & 790       & 783       & 752       & 775.00      & 0.21  \\
50\%      & 163       & 944       & 904       & 892       & 913.33      & 0.18 
\end{tabular}
\caption{Window Size=5}
\label{my-label}
\end{table}


\begin{table}[H]
\begin{tabular}{l|llllll}
drop rate & required & actual 1 & actual 2 & actual 3 & avg actual & ratio \\ \hline
5\%       & 163       & 223       & 279       & 271       & 257.67      & 0.63  \\
10\%      & 163       & 398       & 413       & 379       & 396.67      & 0.41  \\
15\%      & 163       & 561       & 558       & 553       & 557.33      & 0.29  \\
20\%      & 163       & 701       & 681       & 721       & 701      & 0.23  \\
25\%      & 163       & 899       & 918       & 920       & 912.33      & 0.18  \\
30\%      & 163       & 1013       & 998       & 1047       & 1019.33      & 0.16  \\
35\%      & 163       & 1389       & 1369       & 1429       & 1395.67      & 0.12  \\
40\%      & 163       & 1520       & 1498       & 1592      & 1536.67      & 0.11  \\
45\%      & 163       & 1879       & 1903       & 1793       & 1858.33      & 0.08  \\
50\%      & 163       & 2050       & 2102       & 1987       &2046.33      & 0.08
\end{tabular}
\caption{Window Size=11}
\label{my-label}
\end{table}




\begin{table}[H]
\begin{tabular}{l|llllll}
drop rate & required & actual 1 & actual 2 & actual 3 & avg actual & ratio \\ \hline
5\%       & 163       & 259       & 235       & 265       & 253.00      & 0.64  \\
10\%      & 163       & 389       & 372       & 380       & 380.33      & 0.43  \\
15\%      & 163       & 609       & 593       & 617       & 606.33      & 0.27  \\
20\%      & 163       & 879       & 891       & 923      & 897.67      & 0.18  \\
25\%      & 163       & 1248       & 1309      & 1250      & 1269.00      & 0.13  \\
30\%      & 163       & 1390       & 1409       & 1432       & 1410.33      & 0.12  \\
35\%      & 163       & 1678       & 1592       & 1652       & 1640.67      & 0.10  \\
40\%      & 163       & 2387       & 2278       & 2304      & 2323.00      & 0.07  \\
45\%      & 163       & 2651       & 2781       & 2698       & 2710.00      & 0.06  \\
50\%      & 163       & 3098       & 2976       & 3012       & 3028.67      & 0.05 
\end{tabular}
\caption{Window Size=19}
\label{my-label}
\end{table}

\item The following tables contains the nessary data we need to compute the ratio of minimum required packet and actual number of packets sent when the window size and the delay rate changes, keeping the drop rate to 0.
\begin{table}[H]
\centering
\begin{tabular}{l|lll}
delay rate & required & actual  & ratio \\ \hline
5\%       & 163    &178   &0.91  \\
10\%      & 163   &193   & 0.84  \\
15\%      & 163   &202   & 0.80 \\
20\%      & 163   &221   &0.74  \\
25\%      & 163   &222   &0.73  \\
30\%      & 163   &238   &0.68  \\
35\%      & 163   &265   &0.62  \\
40\%      & 163   &265   &0.63  \\
45\%      & 163   &259   &0.71  \\
50\%      & 163   &270   &0.60 
\end{tabular}
\caption{Window Size=3}
\label{my-label}
\end{table}

\begin{table}[H]
\centering
\begin{tabular}{l|lll}
delay rate & required & actual  & ratio \\ \hline
5\%       & 163    &193   &0.84  \\
10\%      & 163   &213   & 0.77  \\
15\%      & 163   &238   & 0.68 \\
20\%      & 163   &260   &0.63  \\
25\%      & 163   &338   &0.48  \\
30\%      & 163   &361   &0.45  \\
35\%      & 163   &368   &0.44  \\
40\%      & 163   &340   &0.48  \\
45\%      & 163   &413   &0.39  \\
50\%      & 163   &360   &0.45 
\end{tabular}
\caption{Window Size=5}
\label{my-label}
\end{table}



\begin{table}[H]
\centering
\begin{tabular}{l|lll}
delay rate & required & actual  & ratio \\ \hline
5\%       & 163    &207   &0.79  \\
10\%      & 163   &370   & 0.44  \\
15\%      & 163   &358   & 0.45 \\
20\%      & 163   &417   &0.39  \\
25\%      & 163   &463   &0.35  \\
30\%      & 163   &489   &0.33  \\
35\%      & 163   &475   &0.34  \\
40\%      & 163   &588   &0.28  \\
45\%      & 163   &705   &0.23  \\
50\%      & 163   &894   &0.18 
\end{tabular}
\caption{Window Size=11}
\label{my-label}
\end{table}

\begin{table}[H]
\centering
\begin{tabular}{l|lll}
delay rate & required & actual  & ratio \\ \hline
5\%       & 163    & 212  &0.77  \\
10\%      & 163   &433  & 0.38  \\
15\%      & 163   &429   & 0.38 \\
20\%      & 163   &638   &0.26  \\
25\%      & 163   &987   &0.17  \\
30\%      & 163   &833   &0.20  \\
35\%      & 163   &950   &0.17  \\
40\%      & 163   &866   &0.19  \\
45\%      & 163   &1064   &0.15  \\
50\%      & 163   &1176   &0.14 
\end{tabular}
\caption{Window Size=19}
\label{my-label}
\end{table}
\end{itemize}
\item Ratio-Drop rate Graph

 With the data we collected, we could come up with the following graph.
 
 And we can tell from the graph, for the same window size, that the ratio of required packet number and actual packet number sent becomes smaller when the drop rate increases. And for the same drop rate, the bigger the window size is, the lower the ratio is.
 
 As the required number of packet is fixed in our testing, this means, the higher the drop rate is, the more packets we need to send to guarantee the reliability of the file transfer protocol we designed.

\begin{tikzpicture}[y=3.7cm, x=.3cm,font=\sffamily]
 	%axis
	\draw (0,0) -- coordinate (x axis mid) (50,0);
    	\draw (0,0) -- coordinate (y axis mid) (0,1);
    	%ticks
    	\foreach \x in {0,5,...,50}
     		\draw (\x,1pt) -- (\x,-3pt)
			node[anchor=north] {\x};
    	\foreach \y in {0,0.1,0.2,0.3,0.4,0.5,0.6,0.7,0.8,0.9,1}
     		\draw (1pt,\y) -- (-3pt,\y) 
     			node[anchor=east] {\y}; 
	%labels      
	\node[below=0.8cm] at (x axis mid) {drop rate(\%)};
	\node[rotate=90, above=0.8cm] at (y axis mid) {ratio};

	%plots
	\draw plot[mark=*, mark options={fill=white}] 
		file {ws1.data};
	\draw plot[mark=* ] 
		file {ws3.data};
        \draw plot[mark=*, mark options={fill=red}] 
		file {ws5.data};
        \draw plot[mark=*, mark options={fill=blue} ] 
		file {ws11.data};
	\draw plot[mark=*, mark options={fill=yellow} ] 
		file {ws19.data};
	 
    
	%legend
	\begin{scope}[shift={(0.5,0.05)}] 
	\draw (0,0) -- 
		plot[mark=*, mark options={fill=white}] (0.05,0) -- (0.5,0) 
		node[right]{window size=1};
	\draw[yshift=7] (0,0) -- 
		plot[mark=*] (0.05,0) -- (0.5,0)
		node[right]{window size=3};
        \draw[yshift=14] (0,0) -- 
		plot[mark=*, mark options={fill=red}] (0.05,0) -- (0.5,0)
		node[right]{window size=5};
        \draw[yshift=21] (0,0) -- 
		plot[mark=*, mark options={fill=blue}] (0.05,0) -- (0.5,0)
		node[right]{window size=11};
        \draw[yshift=28] (0,0) -- 
		plot[mark=*, mark options={fill=yellow}] (0.05,0) -- (0.5,0)
		node[right]{window size=19};
	
	\end{scope}
\end{tikzpicture}

\item Ratio-Delay rate Graph

With the data we collected, we could have the following graph.

We could tell from the graph that, in general, the larger the window size is, the lower ratio could be, that is to say more packets need to be sent. And for each window size, the change of ratio with the increass of the delay rate is smooth.

\begin{tikzpicture}[y=3.7cm, x=.3cm,font=\sffamily]
 	%axis
	\draw (0,0) -- coordinate (x axis mid) (50,0);
    	\draw (0,0) -- coordinate (y axis mid) (0,1);
    	%ticks
    	\foreach \x in {0,5,...,50}
     		\draw (\x,1pt) -- (\x,-3pt)
			node[anchor=north] {\x};
    	\foreach \y in {0,0.1,0.2,0.3,0.4,0.5,0.6,0.7,0.8,0.9,1}
     		\draw (1pt,\y) -- (-3pt,\y) 
     			node[anchor=east] {\y}; 
	%labels      
	\node[below=0.8cm] at (x axis mid) {delay rate(\%)};
	\node[rotate=90, above=0.8cm] at (y axis mid) {ratio};

	%plots
	\draw plot[mark=*, mark options={fill=white}] 
		file {delay1.data};
	\draw plot[mark=* ] 
		file {delay5.data};

        \draw plot[mark=*, mark options={fill=blue} ] 
		file {delay11.data};
	\draw plot[mark=*, mark options={fill=red} ] 
		file {delay19.data};
	 
    
	%legend
	\begin{scope}[shift={(0.5,0.05)}] 
	\draw (0,0) -- 
		plot[mark=*, mark options={fill=white}] (0.05,0) -- (0.5,0) 
		node[right]{window size=3};
	\draw[yshift=8] (0,0) -- 
		plot[mark=*] (0.05,0) -- (0.5,0)
		node[right]{window size=5};
       
        \draw[yshift=16] (0,0) -- 
		plot[mark=*, mark options={fill=blue}] (0.05,0) -- (0.5,0)
		node[right]{window size=11};
        \draw[yshift=24] (0,0) -- 
		plot[mark=*, mark options={fill=red}] (0.05,0) -- (0.5,0)
		node[right]{window size=19};
	
	\end{scope}
\end{tikzpicture}
\end{enumerate}
\end{document}